package ch89;

import java.util.Scanner;

public class dwc {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入要查询素数的范围的最大值：");
        int N = scanner.nextInt();
        int m = 0; int j;
        for(int i = 2; i <= N; i++){
            int k = (int)Math.sqrt(i);
            for ( j = 2; j <= k; j++)
                if (i%j == 0)
                    break;
            if (j > k)
            {
                System.out.printf("%6d", i);
                m++;
                if(m == 5){
                    System.out.println();
                    m = 0;
                }
            }
        }
    }
}
